﻿using System;
using System.Configuration;

using MSAcademic.v2.Infrastructure.Article;
using MSAcademic.v2.Infrastructure.Picture;

namespace MSAcademic.v2.Web.Areas.Admin.Models.Picture
{
    public partial class EditArticleNormalPictureViewModel
    {
        public int ArticleId { get; set; }
        public string OriginalUrl { get; set; }
        public string CroppedNormalPictureUrl { get; set; }

        public double NormalPictureWidth
        {
            get { return Convert.ToInt32(ConfigurationManager.AppSettings["ArticleNormalPictureWidth"]); }
        }

        public double NormalPictureHeight
        {
            get { return Convert.ToInt32(ConfigurationManager.AppSettings["ArticleNormalPictureHeight"]); }
        }
    }
    public partial class EditArticleNormalPictureViewModel
    {
        public string NormalPictureUrl
        {
            get
            {
                if (_normalPictureUrl == null)
                {
                    _normalPictureUrl = new Lazy<string>(() => _iPictureService.GetOriginalPictureUrl(_iArticleQueries.GetArticle(ArticleId).PictureUrlNormal));
                }
                return _normalPictureUrl.Value;
            }
        }
        private Lazy<string> _normalPictureUrl;
    }
    public partial class EditArticleNormalPictureViewModel
    {
        private readonly IArticleQueries _iArticleQueries;
        private readonly IPictureService _iPictureService;
        public EditArticleNormalPictureViewModel(IArticleQueries iArticleQueries, IPictureService iPictureService)
        {
            _iArticleQueries = iArticleQueries;
            _iPictureService = iPictureService;
        }
        public EditArticleNormalPictureViewModel()
        {
            
        }
    }
}